package com.example.bzh.gamecat.ui.society;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.webkit.WebResourceRequest;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.bzh.gamecat.R;
import com.example.bzh.gamecat.base.BaseActivity;

import butterknife.BindView;
import butterknife.OnClick;

public class SecondActivity extends BaseActivity {

    @BindView(R.id.web_view_second)
    WebView webViewSecond;
    @BindView(R.id.iv_back)
    ImageView ivBack;
    @BindView(R.id.tv_title_second)
    TextView tvTitleSecond;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Intent intent = getIntent();
        final String weburl = intent.getStringExtra("weburl");
        String title = intent.getStringExtra("title");
        if (title != null) {
            tvTitleSecond.setText(title);
        }
        WebSettings settings = webViewSecond.getSettings();
        settings.setJavaScriptEnabled(true);
        settings.getAllowFileAccess();
        settings.setBuiltInZoomControls(true);
        webViewSecond.loadUrl(weburl);
        webViewSecond.setWebViewClient(new WebViewClient(){
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
                view.loadUrl(weburl);
                return true;
            }
        });


    }

    @Override
    public void initData() {
        super.initData();
    }

    @Override
    public void initView() {
        super.initView();
    }

    @Override
    public int getLayoutId() {
        return R.layout.activity_second;
    }

    @OnClick(R.id.iv_back)
    public void onClick() {
        finish();
    }
}
